// Copyright (c) [Year] [name of copyright holder]
// [Software Name] is licensed under Mulan PSL v2.
// You can use this software according to the terms and conditions of the Mulan PSL v2. 
// You may obtain a copy of Mulan PSL v2 at:
//          http://license.coscl.org.cn/MulanPSL2 
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.  
// See the Mulan PSL v2 for more details.

/*!
 * \autor captainpeng
 * \date 2019-11-3
 * \version 1.0
 */

#ifndef MY_GENCODE_HPP
#define MY_GENCODE_HPP

#include"mystd.hpp"
#include"seq.hpp"
#include"typeLib.hpp"

namespace my{

    class genCode{
    private:
        std::stringstream mOS;
        int mLen;
        char * mBuf;

        static constexpr char * funcFmt = "%s %s(%s,){ %s }";

        static int count = 0;
        
    public:
        genCode(){
            mLen = 4096;
            mBuf = new char[mLen];
        }

        ~genCode(){
            if(mBuf != nullptr){
                delete [] mBuf;
                mBuf = nullptr;
            }
        }
        
        template<class R, class ... Args>
        void beginFunc(const std::string & name){
            const char * ret(typeName<R>::cstr());
            const char * args[sizeof ... (Args)];
            
            using tuple = typeTuple<Args...>;
            for(int i = 0; i < tuple::size; ++i){
                args[i] = typeName<typename tuple::get_t<i>>::cstr();
            }

            
        }
    };

    int genCode::count;
}

#endif
